﻿<!--
 * @Author: 哈兰德
 * @Description: 图片广告主模块
-->
<template>
  <div class="image-cssEditor">
    <editor-panel title="图片属性">
      <div>
        <template-list
          :template-list="templateList"
          :selected-template="selectedTemplate"
          @setCurrentTemplate="setTemplateObj"
        />
        <draggable-list
          ref="imageDraggerRef"
          :activity-code="activityCode"
          :selected-template="selectedTemplate"
          @addStep="addStep"
        />
        <div class="el-card__header">
          样式属性
        </div>
        <style-form
          ref="styleFormRef"
          :selected-template="selectedTemplate"
          @addStep="addStep"
        />
      </div>
    </editor-panel>
  </div>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex'
import TemplateList from './components/TemplateList/index'
import DraggableList from './components/DraggableList/index'
import StyleForm from './components/StyleForm/index'
import EditorPanel from '@/components/properties/common/EditorPanel'

export default {
  components: {
    EditorPanel,
    TemplateList,
    DraggableList,
    StyleForm
  },
  props: {
    activityCode: {
      type: String,
      default: ''
    },
  },
  data () {
    return {
      tag: true,
      templateList: [
        {
          id: 1,
          name: '一行一个',
          icon: '/images/imgad/imgad1.png',
          icon_on: '/images/imgad/imgad1_on.png',
        },
        {
          id: 2,
          name: '轮播海报',
          icon: '/images/imgad/imgad2.png',
          icon_on: '/images/imgad/imgad2_on.png',
        },
        {
          id: 3,
          name: '横向滑动（大图）',
          icon: '/images/imgad/imgad3.png',
          icon_on: '/images/imgad/imgad3_on.png',
        },
        {
          id: 4,
          name: '横向滑动（小图）',
          icon: '/images/imgad/imgad4.png',
          icon_on: '/images/imgad/imgad4_on.png',
        },
      ],
      selectedTemplate: {}
    }
  },
  computed: {
    ...mapGetters('main', ['selectedComponent', 'pageContent']),
  },
  methods: {
    ...mapMutations('main', ['editComponent']),
    ...mapMutations('step', ['stepsAdd1']),
    setTemplateObj(item) {
      this.selectedTemplate = item
      this.$refs.imageDraggerRef.initData()
      this.$refs.styleFormRef.initData()
    },
    addStep () {
      setTimeout(() => {
        if (this.tag) {
          this.tag = false
          this.stepsAdd1(this.pageContent)
          setTimeout(() => {
            this.tag = true
          }, 500)
        }
      }, 200)
    }
  }
}
</script>

<style lang="less" scoped>
.image-cssEditor {
  // width: 400px;
  .el-card {
    border: 0 !important;
  }
  margin-top: 10px;
  .el-card__header {
    background-color: #f5f7fa !important;
    padding: 0 20px;
    height: 40px;
    line-height: 40px;
    color: #409eff;
    border: 0;
    i {
      margin-left: 205px;
      font-size: 16px;
    }
  }
  .el-card__body {
    padding: 0px;
    overflow-y: auto;
    .el-form-item {
      margin-bottom: 10px;
    }
    .el-icon-question {
      font-size: 14px;
    }
    .question {
      font-size: 20px;
      color: #fff;
      vertical-align: middle;
      margin: 5px 0 0 10px;
      position: absolute;
    }
    .tc {
      .el-input__inner {
        text-align: center;
      }
    }
  }
}
</style>